#include <iostream>
using namespace std;

class Y {
public:
  int yy;

  friend  bool operator==(const Y& lhs, const Y& rhs);
  Y(){ cout<<"Y()"<<endl;}
  ~Y(){cout<<"~Y()"<<endl;}
};
bool operator==(const Y& lhs, const Y& rhs)
{
  cout<<"Y::operator==()"<<endl;
  return(lhs.yy==rhs.yy);
}
class X {
public:
  float xx;

  operator Y() const{ cout<<"X::operator Y()"<<endl;Y y; y.yy = (int)xx; return y;}
  X(){ cout<<"X()"<<endl;}
  ~X(){cout<<"~X()"<<endl;}
};



int main()
{
  Y y;
  y.yy = 12;
  X x1;
  x1.xx = 12.0;
  X x2;
  x2.xx = 1212.0;
  cout<<"--------------"<<endl;
  if(y == x1){
    cout<<"y==x1"<<endl;
  }
  cout<<"--------------"<<endl;
  if(y == x2){
    cout<<"x2==y"<<endl;
  }
  cout<<"--------------"<<endl;
  return 0;
}
